﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace AspNetThemesExtensions
{
    public class ThemesExtensionsModule : IHttpModule
    {
        private static bool _init = false;
        private static object _lockObject = new object();

        public void Dispose()
        {
            
        }

        public void Init(HttpApplication context)
        {
            if(!_init)
            {
                lock(_lockObject)
                {
                    if(!_init)
                    {
                        ThemeVirtualPathProvider vpp = new ThemeVirtualPathProvider();
                        System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(vpp);
                        _init = true;
                    }
                }
            }
        }
    }
}
